<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0px;

        }
        body{
            height: 2000px;
        }
        div{
            width: 300px;
            height: 300px;
            background-color: red;
            margin-top: 200px;
            margin-left: 300px;
        }
    </style>
</head>
<body>
    <div >
        

    </div>

    <script>
        var div1=document.querySelector('div');
        div1.addEventListener('click',function(e){
            // page  - offset
            // x坐标
            var x = e.pageX - div1.offsetLeft;
            // y坐标
            var y = e.pageY - div1.offsetTop;
            div1.innerHTML='x:'+x+'  y:'+y;
        }); 
    </script>
</body>
</html>